package com.efounder.addressselector.greendao;

import java.util.Map;

import org.greenrobot.greendao.AbstractDao;
import org.greenrobot.greendao.AbstractDaoSession;
import org.greenrobot.greendao.database.Database;
import org.greenrobot.greendao.identityscope.IdentityScopeType;
import org.greenrobot.greendao.internal.DaoConfig;

import com.efounder.addressselector.model.County;
import com.efounder.addressselector.model.Province;
import com.efounder.addressselector.model.City;
import com.efounder.addressselector.model.Street;

import com.efounder.addressselector.greendao.CountyDao;
import com.efounder.addressselector.greendao.ProvinceDao;
import com.efounder.addressselector.greendao.CityDao;
import com.efounder.addressselector.greendao.StreetDao;

// THIS CODE IS GENERATED BY greenDAO, DO NOT EDIT.

/**
 * {@inheritDoc}
 * 
 * @see org.greenrobot.greendao.AbstractDaoSession
 */
public class DaoSession extends AbstractDaoSession {

    private final DaoConfig countyDaoConfig;
    private final DaoConfig provinceDaoConfig;
    private final DaoConfig cityDaoConfig;
    private final DaoConfig streetDaoConfig;

    private final CountyDao countyDao;
    private final ProvinceDao provinceDao;
    private final CityDao cityDao;
    private final StreetDao streetDao;

    public DaoSession(Database db, IdentityScopeType type, Map<Class<? extends AbstractDao<?, ?>>, DaoConfig>
            daoConfigMap) {
        super(db);

        countyDaoConfig = daoConfigMap.get(CountyDao.class).clone();
        countyDaoConfig.initIdentityScope(type);

        provinceDaoConfig = daoConfigMap.get(ProvinceDao.class).clone();
        provinceDaoConfig.initIdentityScope(type);

        cityDaoConfig = daoConfigMap.get(CityDao.class).clone();
        cityDaoConfig.initIdentityScope(type);

        streetDaoConfig = daoConfigMap.get(StreetDao.class).clone();
        streetDaoConfig.initIdentityScope(type);

        countyDao = new CountyDao(countyDaoConfig, this);
        provinceDao = new ProvinceDao(provinceDaoConfig, this);
        cityDao = new CityDao(cityDaoConfig, this);
        streetDao = new StreetDao(streetDaoConfig, this);

        registerDao(County.class, countyDao);
        registerDao(Province.class, provinceDao);
        registerDao(City.class, cityDao);
        registerDao(Street.class, streetDao);
    }
    
    public void clear() {
        countyDaoConfig.clearIdentityScope();
        provinceDaoConfig.clearIdentityScope();
        cityDaoConfig.clearIdentityScope();
        streetDaoConfig.clearIdentityScope();
    }

    public CountyDao getCountyDao() {
        return countyDao;
    }

    public ProvinceDao getProvinceDao() {
        return provinceDao;
    }

    public CityDao getCityDao() {
        return cityDao;
    }

    public StreetDao getStreetDao() {
        return streetDao;
    }

}
